package com.sfh.tourist;

import com.sfh.lib.AppCacheManager;
import com.sfh.lib.http.HttpMediaType;

import java.io.File;

import com.sfh.tourist.base.LuBanFactory;

public class ReqFile extends ReqBase<Result<String>> {

    // {"code":1,"message":"上传成功","data":"http://localhost:8081/image/202005042005042212190002.jpg","successed":true}
    public File file;

    public ReqFile(File file) {
        super("/api/moPoint/uploadFile");
        setMediaType(HttpMediaType.MEDIA_TYPE_MULTIPART_FORM);
        this.file = file;
    }

    @Override
    public Object buildParam() {
        try {
            File dstFile = new File(AppCacheManager.getFileCache(),System.currentTimeMillis()+".jpg");
            File newfile = LuBanFactory.compress(file,dstFile,500);
            if (newfile != null){
                file =newfile;
            }
        }catch (Exception e){}
        return super.buildParam();
    }

}
